package com.my.test.service.util;

import java.util.Random;

public class RequestTraceContext {
    private static final ThreadLocal<RequestTraceContext> requestContextTl = new ThreadLocal();
    private long id;

    public RequestTraceContext() {
        this.id=genLong();
    }

    public RequestTraceContext(long id) {
        this.id = id;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public static RequestTraceContext get() {
        return requestContextTl.get();
    }

    public static void init() {
        requestContextTl.set(new RequestTraceContext());
    }

    public static Long genLong() {
        return new Random().nextLong();
    }
}